<?php
$data = $view->getTableData();
$fields = $view->getOrderedFieldList(); ?>

<table class="datatable" cellspacing="0">
	<thead>
		<tr>
<?php foreach($fields as $field) {
	$dir = "asc";
	$class = "";
	if ($view->sort["by"] == $field->name) {
		$dir = $view->switchOrderDir($view->sort["dir"]);
		$class = $view->sort["dir"];
	} ?>
			<th>
				<a
					class="<?php echo $class;?>"
					href="/<?php echo $view->modelname; ?>/table/?sortby=<?php echo $field->name; ?>&sortdir=<?php echo $dir; ?>"
					title="Sort <?php echo $dir; ?>"
				>
					<?php echo $field->caption; ?>
				</a>
			</th>
<?php } ?>
			<th></th>
		</tr>
	</thead>
	<tbody>
<?php foreach($data as $row) { ?>
		<tr>
<?php foreach($fields as $field) { ?>
			<td>
				<?php echo $field->render($row->{$field->name}); ?>
			</td>		
<?php } ?>
			<td>
				<a href="/<?php echo $view->modelname; ?>/detail/?id=<?php echo $row->id; ?>">
					<?php echo html::icon("proceed"); ?>
				</a>
			</td>
		</tr>
<?php } ?>
	</tbody>
</table>